package com.google.android.gcm;

import android.app.AlarmManager;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.SystemClock;
import android.util.Log;
import java.util.Random;
import java.util.concurrent.TimeUnit;

public abstract class GCMBaseIntentService extends IntentService
{
  private static final String EXTRA_TOKEN = "token";
  private static final Object LOCK = GCMBaseIntentService.class;
  private static final int MAX_BACKOFF_MS = 0;
  public static final String TAG = "GCMBaseIntentService";
  private static final String TOKEN = Long.toBinaryString(sRandom.nextLong());
  private static final String WAKELOCK_KEY = "GCM_LIB";
  private static int sCounter = 0;
  private static final Random sRandom = new Random();
  private static PowerManager.WakeLock sWakeLock;
  protected String mSenderId;

  protected GCMBaseIntentService()
  {
    super(i);
  }

  private void handleRegistration(Context paramContext, Intent paramIntent)
  {
    String str1 = paramIntent.getStringExtra("registration_id");
    String str2 = paramIntent.getStringExtra("error");
    String str3 = paramIntent.getStringExtra("unregistered");
    Log.d("GCMBaseIntentService", "handleRegistration: registrationId = " + str1 + ", error = " + str2 + ", unregistered = " + str3);
    if (str1 != null)
    {
      GCMRegistrar.resetBackoff(paramContext);
      GCMRegistrar.setRegistrationId(paramContext, str1);
      onRegistered(paramContext, str1);
    }
    int i;
    do
    {
      return;
      if (str3 != null)
      {
        GCMRegistrar.resetBackoff(paramContext);
        onUnregistered(paramContext, GCMRegistrar.clearRegistrationId(paramContext));
        return;
      }
      Log.d("GCMBaseIntentService", "Registration error: " + str2);
      if (!"SERVICE_NOT_AVAILABLE".equals(str2))
        break label287;
      if (!onRecoverableError(paramContext, str2))
        break;
      i = GCMRegistrar.getBackoff(paramContext);
      int j = i / 2 + sRandom.nextInt(i);
      Log.d("GCMBaseIntentService", "Scheduling registration retry, backoff = " + j + " (" + i + ")");
      Intent localIntent = new Intent("com.google.android.gcm.intent.RETRY");
      localIntent.putExtra("token", TOKEN);
      PendingIntent localPendingIntent = PendingIntent.getBroadcast(paramContext, 0, localIntent, 0);
      ((AlarmManager)paramContext.getSystemService("alarm")).set(3, SystemClock.elapsedRealtime() + j, localPendingIntent);
    }
    while (i >= MAX_BACKOFF_MS);
    GCMRegistrar.setBackoff(paramContext, i * 2);
    return;
    Log.d("GCMBaseIntentService", "Not retrying failed operation");
    return;
    label287: onError(paramContext, str2);
  }

  static void runIntentInService(Context paramContext, Intent paramIntent, String paramString)
  {
    synchronized (LOCK)
    {
      if (sWakeLock == null)
        sWakeLock = ((PowerManager)paramContext.getSystemService("power")).newWakeLock(1, "GCM_LIB");
      Log.v("GCMBaseIntentService", "Acquiring wakelock");
      sWakeLock.acquire();
      paramIntent.setClassName(paramContext, paramString);
      paramContext.startService(paramIntent);
      return;
    }
  }

  protected void onDeletedMessages(Context paramContext, int paramInt)
  {
  }

  protected abstract void onError(Context paramContext, String paramString);

  // ERROR //
  public final void onHandleIntent(Intent paramIntent)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual 241	com/google/android/gcm/GCMBaseIntentService:getApplicationContext	()Landroid/content/Context;
    //   4: astore 8
    //   6: aload_1
    //   7: invokevirtual 244	android/content/Intent:getAction	()Ljava/lang/String;
    //   10: astore 9
    //   12: aload 9
    //   14: ldc 246
    //   16: invokevirtual 141	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   19: ifeq +42 -> 61
    //   22: aload_0
    //   23: aload 8
    //   25: aload_1
    //   26: invokespecial 248	com/google/android/gcm/GCMBaseIntentService:handleRegistration	(Landroid/content/Context;Landroid/content/Intent;)V
    //   29: getstatic 30	com/google/android/gcm/GCMBaseIntentService:LOCK	Ljava/lang/Object;
    //   32: astore 13
    //   34: aload 13
    //   36: monitorenter
    //   37: getstatic 204	com/google/android/gcm/GCMBaseIntentService:sWakeLock	Landroid/os/PowerManager$WakeLock;
    //   40: ifnull +434 -> 474
    //   43: ldc 16
    //   45: ldc 250
    //   47: invokestatic 217	android/util/Log:v	(Ljava/lang/String;Ljava/lang/String;)I
    //   50: pop
    //   51: getstatic 204	com/google/android/gcm/GCMBaseIntentService:sWakeLock	Landroid/os/PowerManager$WakeLock;
    //   54: invokevirtual 253	android/os/PowerManager$WakeLock:release	()V
    //   57: aload 13
    //   59: monitorexit
    //   60: return
    //   61: aload 9
    //   63: ldc 255
    //   65: invokevirtual 141	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   68: ifeq +234 -> 302
    //   71: aload_1
    //   72: ldc_w 257
    //   75: invokevirtual 91	android/content/Intent:getStringExtra	(Ljava/lang/String;)Ljava/lang/String;
    //   78: astore 23
    //   80: aload 23
    //   82: ifnull +160 -> 242
    //   85: aload 23
    //   87: ldc_w 259
    //   90: invokevirtual 141	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   93: ifeq +122 -> 215
    //   96: aload_1
    //   97: ldc_w 261
    //   100: invokevirtual 91	android/content/Intent:getStringExtra	(Ljava/lang/String;)Ljava/lang/String;
    //   103: astore 25
    //   105: aload 25
    //   107: ifnull -78 -> 29
    //   110: aload 25
    //   112: invokestatic 267	java/lang/Integer:parseInt	(Ljava/lang/String;)I
    //   115: istore 28
    //   117: ldc 16
    //   119: new 67	java/lang/StringBuilder
    //   122: dup
    //   123: ldc_w 269
    //   126: invokespecial 72	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   129: iload 28
    //   131: invokevirtual 76	java/lang/StringBuilder:append	(I)Ljava/lang/StringBuilder;
    //   134: invokevirtual 80	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   137: invokestatic 217	android/util/Log:v	(Ljava/lang/String;Ljava/lang/String;)I
    //   140: pop
    //   141: aload_0
    //   142: aload 8
    //   144: iload 28
    //   146: invokevirtual 271	com/google/android/gcm/GCMBaseIntentService:onDeletedMessages	(Landroid/content/Context;I)V
    //   149: goto -120 -> 29
    //   152: astore 26
    //   154: ldc 16
    //   156: new 67	java/lang/StringBuilder
    //   159: dup
    //   160: ldc_w 273
    //   163: invokespecial 72	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   166: aload 25
    //   168: invokevirtual 100	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   171: invokevirtual 80	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   174: invokestatic 276	android/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)I
    //   177: pop
    //   178: goto -149 -> 29
    //   181: astore_2
    //   182: getstatic 30	com/google/android/gcm/GCMBaseIntentService:LOCK	Ljava/lang/Object;
    //   185: astore 4
    //   187: aload 4
    //   189: monitorenter
    //   190: getstatic 204	com/google/android/gcm/GCMBaseIntentService:sWakeLock	Landroid/os/PowerManager$WakeLock;
    //   193: ifnull +257 -> 450
    //   196: ldc 16
    //   198: ldc 250
    //   200: invokestatic 217	android/util/Log:v	(Ljava/lang/String;Ljava/lang/String;)I
    //   203: pop
    //   204: getstatic 204	com/google/android/gcm/GCMBaseIntentService:sWakeLock	Landroid/os/PowerManager$WakeLock;
    //   207: invokevirtual 253	android/os/PowerManager$WakeLock:release	()V
    //   210: aload 4
    //   212: monitorexit
    //   213: aload_2
    //   214: athrow
    //   215: ldc 16
    //   217: new 67	java/lang/StringBuilder
    //   220: dup
    //   221: ldc_w 278
    //   224: invokespecial 72	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   227: aload 23
    //   229: invokevirtual 100	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   232: invokevirtual 80	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   235: invokestatic 276	android/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)I
    //   238: pop
    //   239: goto -210 -> 29
    //   242: aload 8
    //   244: invokestatic 284	com/arellomobile/android/push/utils/PreferenceUtils:getLightScreenOnNotification	(Landroid/content/Context;)Z
    //   247: istore 30
    //   249: aconst_null
    //   250: astore 31
    //   252: iload 30
    //   254: ifeq +28 -> 282
    //   257: aload_0
    //   258: ldc 206
    //   260: invokevirtual 285	com/google/android/gcm/GCMBaseIntentService:getSystemService	(Ljava/lang/String;)Ljava/lang/Object;
    //   263: checkcast 208	android/os/PowerManager
    //   266: ldc_w 286
    //   269: ldc_w 288
    //   272: invokevirtual 212	android/os/PowerManager:newWakeLock	(ILjava/lang/String;)Landroid/os/PowerManager$WakeLock;
    //   275: astore 31
    //   277: aload 31
    //   279: invokevirtual 222	android/os/PowerManager$WakeLock:acquire	()V
    //   282: aload_0
    //   283: aload 8
    //   285: aload_1
    //   286: invokevirtual 291	com/google/android/gcm/GCMBaseIntentService:onMessage	(Landroid/content/Context;Landroid/content/Intent;)V
    //   289: aload 31
    //   291: ifnull -262 -> 29
    //   294: aload 31
    //   296: invokevirtual 253	android/os/PowerManager$WakeLock:release	()V
    //   299: goto -270 -> 29
    //   302: aload 9
    //   304: ldc 161
    //   306: invokevirtual 141	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   309: ifeq -280 -> 29
    //   312: aload_1
    //   313: ldc 8
    //   315: invokevirtual 91	android/content/Intent:getStringExtra	(Ljava/lang/String;)Ljava/lang/String;
    //   318: astore 10
    //   320: getstatic 65	com/google/android/gcm/GCMBaseIntentService:TOKEN	Ljava/lang/String;
    //   323: aload 10
    //   325: invokevirtual 141	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   328: ifne +82 -> 410
    //   331: ldc 16
    //   333: new 67	java/lang/StringBuilder
    //   336: dup
    //   337: ldc_w 293
    //   340: invokespecial 72	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   343: aload 10
    //   345: invokevirtual 100	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   348: invokevirtual 80	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   351: invokestatic 276	android/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)I
    //   354: pop
    //   355: getstatic 30	com/google/android/gcm/GCMBaseIntentService:LOCK	Ljava/lang/Object;
    //   358: astore 19
    //   360: aload 19
    //   362: monitorenter
    //   363: getstatic 204	com/google/android/gcm/GCMBaseIntentService:sWakeLock	Landroid/os/PowerManager$WakeLock;
    //   366: ifnull +32 -> 398
    //   369: ldc 16
    //   371: ldc 250
    //   373: invokestatic 217	android/util/Log:v	(Ljava/lang/String;Ljava/lang/String;)I
    //   376: pop
    //   377: getstatic 204	com/google/android/gcm/GCMBaseIntentService:sWakeLock	Landroid/os/PowerManager$WakeLock;
    //   380: invokevirtual 253	android/os/PowerManager$WakeLock:release	()V
    //   383: aload 19
    //   385: monitorexit
    //   386: return
    //   387: astore 20
    //   389: aload 19
    //   391: monitorexit
    //   392: aload 20
    //   394: athrow
    //   395: astore 18
    //   397: return
    //   398: ldc 16
    //   400: ldc_w 295
    //   403: invokestatic 276	android/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)I
    //   406: pop
    //   407: goto -24 -> 383
    //   410: aload 8
    //   412: invokestatic 298	com/google/android/gcm/GCMRegistrar:isRegistered	(Landroid/content/Context;)Z
    //   415: ifeq +11 -> 426
    //   418: aload 8
    //   420: invokestatic 301	com/google/android/gcm/GCMRegistrar:internalUnregister	(Landroid/content/Context;)V
    //   423: goto -394 -> 29
    //   426: iconst_1
    //   427: anewarray 137	java/lang/String
    //   430: astore 11
    //   432: aload 11
    //   434: iconst_0
    //   435: aload_0
    //   436: getfield 303	com/google/android/gcm/GCMBaseIntentService:mSenderId	Ljava/lang/String;
    //   439: aastore
    //   440: aload 8
    //   442: aload 11
    //   444: invokestatic 307	com/google/android/gcm/GCMRegistrar:internalRegister	(Landroid/content/Context;[Ljava/lang/String;)V
    //   447: goto -418 -> 29
    //   450: ldc 16
    //   452: ldc_w 295
    //   455: invokestatic 276	android/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)I
    //   458: pop
    //   459: goto -249 -> 210
    //   462: astore 5
    //   464: aload 4
    //   466: monitorexit
    //   467: aload 5
    //   469: athrow
    //   470: astore_3
    //   471: goto -258 -> 213
    //   474: ldc 16
    //   476: ldc_w 295
    //   479: invokestatic 276	android/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)I
    //   482: pop
    //   483: goto -426 -> 57
    //   486: astore 14
    //   488: aload 13
    //   490: monitorexit
    //   491: aload 14
    //   493: athrow
    //   494: astore 12
    //   496: return
    //
    // Exception table:
    //   from	to	target	type
    //   110	149	152	java/lang/NumberFormatException
    //   0	29	181	finally
    //   61	80	181	finally
    //   85	105	181	finally
    //   110	149	181	finally
    //   154	178	181	finally
    //   215	239	181	finally
    //   242	249	181	finally
    //   257	282	181	finally
    //   282	289	181	finally
    //   294	299	181	finally
    //   302	355	181	finally
    //   410	423	181	finally
    //   426	447	181	finally
    //   363	383	387	finally
    //   383	386	387	finally
    //   389	392	387	finally
    //   398	407	387	finally
    //   355	363	395	java/lang/Exception
    //   392	395	395	java/lang/Exception
    //   190	210	462	finally
    //   210	213	462	finally
    //   450	459	462	finally
    //   464	467	462	finally
    //   182	190	470	java/lang/Exception
    //   467	470	470	java/lang/Exception
    //   37	57	486	finally
    //   57	60	486	finally
    //   474	483	486	finally
    //   488	491	486	finally
    //   29	37	494	java/lang/Exception
    //   491	494	494	java/lang/Exception
  }

  protected abstract void onMessage(Context paramContext, Intent paramIntent);

  protected boolean onRecoverableError(Context paramContext, String paramString)
  {
    return true;
  }

  protected abstract void onRegistered(Context paramContext, String paramString);

  protected abstract void onUnregistered(Context paramContext, String paramString);
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.google.android.gcm.GCMBaseIntentService
 * JD-Core Version:    0.6.2
 */